package com.linkhub.oms.admin.modules.logistic.freighttemplate.domain.vo;

import cn.hutool.core.date.DatePattern;
import com.linkhub.oms.common.util.QtStreamUtil;
import com.linkhub.oms.entity.LogisticFreightTemplateDetailEntity;
import com.linkhub.oms.entity.LogisticFreightTemplateEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * <p>
 * 物流运费模板详情VO
 * </p>
 *
 * @author Frank
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "物流运费模板详情VO", description = "物流运费模板详情VO")
@NoArgsConstructor
public class LogisticFreightTemplateDetailVO implements Serializable {

    @ApiModelProperty(value = "主键")
    private Long id;

    @ApiModelProperty(value = "模板名称")
    private String templateName;

    @ApiModelProperty(value = "模板生效日期")
    private String effectiveDate;

    @ApiModelProperty(value = "模板失效日期")
    private String expirationDate;

    @ApiModelProperty(value = "渠道编码")
    private String channelCode;

    @ApiModelProperty(value = "渠道中文名称")
    private String channelCName;

    @ApiModelProperty(value = "渠道英文名称")
    private String channelEName;

    @ApiModelProperty(value = "国家编码")
    private String countryCode;

    @ApiModelProperty(value = "国家分区")
    private String countryPartition;

    @ApiModelProperty(value = "计泡系数")
    private Integer bubbleCoefficient;

    @ApiModelProperty(value = "最低计费重量")
    private BigDecimal minimumChargeableWeight;

    @ApiModelProperty(value = "实际费用币种")
    private String actualFeeCurrencyType;

    @ApiModelProperty(value = "进位方式 1：默认（不进位） 2：向上取整")
    private Integer carryMethod;

    @ApiModelProperty(value = "重量范围")
    private List<FreightTemplateDetailVO> templateDetails;

    public LogisticFreightTemplateDetailVO(LogisticFreightTemplateEntity entity, List<LogisticFreightTemplateDetailEntity> detailEntities) {
        this.id = entity.getId();
        this.templateName = entity.getTemplateName();
        this.effectiveDate = entity.getEffectiveDate().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
        this.expirationDate = entity.getExpirationDate().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
        this.channelCode = entity.getChannelCode();
        this.channelCName = entity.getChannelCName();
        this.channelEName = entity.getChannelEName();
        this.countryCode = entity.getCountryCode();
        this.countryPartition = entity.getCountryPartition();
        this.bubbleCoefficient = entity.getBubbleCoefficient();
        this.minimumChargeableWeight = entity.getMinimumChargeableWeight();
        this.actualFeeCurrencyType = entity.getActualFeeCurrencyType();
        this.carryMethod = entity.getCarryMethod();
        this.templateDetails = QtStreamUtil.map(detailEntities, FreightTemplateDetailVO::new);
    }


}
